package asTest;

import java.util.Scanner;

public class Main{

    public static int[] mergeTwoArray(int[] a, int[] b){
        int aLen = a.length;
        int bLen = b.length;

        int[] res = new int[aLen + bLen];

        int index = 0;
        int i = 0;
        int j = 0;

        while(i < aLen && j < bLen){
            if(a[i] <= b[j]){
                res[index] = a[i];
                i++;
            }else{
                res[index] = b[j];
                j++;
            }
            index ++;
        }

        if(i < aLen){
            for(int x=i; x<aLen; x++){
                res[index++] = a[x];
            }
        }

        if(j < bLen){
            for(int x=j; x<bLen; x++){
                res[index++] = b[x];
            }
        }

        return res;
    }



    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int[] arr1;
        int[] arr2;
        while (in.hasNextInt()) {// 注意，如果输入是多个测试用例，请通过while循环处理多个测试用例
            String s = in.nextLine();

            String[] strs = s.split(" ");

            int aLen = Integer.valueOf(strs[0]);
            int bLen = Integer.valueOf(strs[1]);

            arr1 = new int[aLen];
            arr2 = new int[bLen];

            String s2 = in.nextLine();
            String[] strs2 = s2.split(" ");
            for(int i = 0; i < aLen; i++){
                arr1[i] = Integer.valueOf(strs2[i]);
            }

            String s3 = in.nextLine();
            String[] strs3 = s3.split(" ");
            for(int i = 0; i < bLen; i++){
                arr2[i] = Integer.valueOf(strs3[i]);
            }

            int[] res = mergeTwoArray(arr1, arr2);

            for(int i = 0; i < res.length; i++){
                System.out.print(res[i] + " ");
            }
        }
    }
}